#!/usr/bin/perl
while (<>) {                   # take one input line at a time
    chomp;
    if (
        m{
            (\b\w*a\b)
            (.{0,5})
        }xs
    ){
        print "Matched: |$1 -> $2|\n";  # the special match vars
        #print "'word' contains '$+{word}'\n";
    } else {
        print "No match: |$_|\n";
    }
}
